package com.wenbo.wenbo.controller;

import com.wenbo.wenbo.kafka.KafkaProducer;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author ywb
 * @date 2021年12月17日 11:05
 */
@RestController
@RequestMapping("/kafka")
public class KafkaController {

    @Resource
    private KafkaProducer kafkaProducer;

    @GetMapping("/sendMsg")
    public void sendMsg(int i,int k) throws InterruptedException {
        if(i==0){
            i=1;
        }
        if(k==0){
            k=50;
        }
        kafkaProducer.send(i,k);
    }

    @GetMapping("/sendMsg2")
    public void sendMsg2(int i,int k) throws InterruptedException {
        if(i==0){
            i=1;
        }
        if(k==0){
            k=50;
        }
        kafkaProducer.send2(i,k);
    }
}
